package com.css.fxfzxczh.modules.remoteSenseData.repository.impl;

import com.css.fxfzxczh.constants.YNEnum;
import com.css.fxfzxczh.modules.remoteSenseData.entity.RemoteSenseSupplement;
import com.css.fxfzxczh.modules.remoteSenseData.repository.RemoteSenseSupplementRepository;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author:
 * @CreateTime: 2024/3/11 16:35
 * @Description:
 */
@Repository
public class remoteSenseSupplementRepositoryImpl implements RemoteSenseSupplementRepository {

    @Resource
    NamedParameterJdbcTemplate namedParameterJdbcTemplate;

    @Override
    public void batchSave(List<RemoteSenseSupplement> list) {
        SqlParameterSource[] beanSources = SqlParameterSourceUtils.createBatch(list.toArray());
        String sql = "INSERT INTO xczh_remote_sense_supplement ( id,xrs_id,structure_type,structure_proportion," +
                "destroy,serious_damage,medium_damage,slight_damage,basically_intact,floor_space)" +
                "values (:id,:xrsId,:structureType,:structureProportion,:destroy,:seriousDamage,:mediumDamage," +
                ":slightDamage,:basicallyIntact,:floorSpace)";
        namedParameterJdbcTemplate.batchUpdate(sql, beanSources);
    }

    @Override
    public void delete(List<String> ids) {
        String sql = "delete from xczh_remote_sense_supplement where xrs_id in (:ids)";
        Map map = new HashMap();
        map.put("ids", ids);
        namedParameterJdbcTemplate.update(sql, map);
    }
}
